package insight.jsp.custom.taglib;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

public class GridToolbarTagHandler extends TagSupport {
	private static final long serialVersionUID = 1L;
	private String id;
	@Override
	public int doStartTag() throws JspException {
		try {
			// pageContext.getSession()
			JspWriter out = pageContext.getOut();
			String strOut = buildOutput();
			out.println(strOut);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}	

	private String buildOutput() {
		String strOut="<div class=\"row\">";
		strOut+="<div id=\"" +  id + "\" class=\"ra-section\"></div>";
		strOut+="</div>";
		
		strOut+="<script id=\"" +  id + "Template\" type=\"text/x-kendo-template\">";
		strOut+= "<div class=\"btn-group\">";
		
		strOut += "<button type=\"button\" class=\"btn btn-default\" btnaction=\"addNew\">";
		strOut += "<span class=\"fa fa-plus-square-o fa-lg\"></span>";
		strOut += "</button>";

		strOut += "<button type=\"button\" class=\"btn btn-default\" btnaction=\"edit\">";
		strOut += "<span class=\"fa fa-pencil-square-o fa-lg\"></span>";
		strOut += "</button>";

		strOut += "<button type=\"button\" class=\"btn btn-default\" btnaction=\"delete\">";
		strOut += "<span class=\"fa fa-trash-o fa-lg\"></span>";
		strOut += "</button>";

		strOut += "<button type=\"button\" class=\"btn btn-default\" btnaction=\"columns\">";
		strOut += "<span class=\"fa fa-columns fa-lg\"></span>";
		strOut += "</button>";

		strOut += "<div class=\"btn-group\">";
		strOut += "<button type=\"button\" class=\"btn btn-default dropdown-toggle\" data-toggle=\"dropdown\">Action <span class=\"caret\"></span>";
		strOut += "</button>";
		strOut += "<ul class=\"dropdown-menu\">";
		strOut += "<li><a href=\"#\">Dropdown link</a></li>";
		strOut += "<li><a href=\"#\">Dropdown link</a></li>";
		strOut += "</ul>";
		strOut += "</div>";
		
		strOut += "</div>";
		strOut += "</script>";
		return strOut;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}
}
